{% extends "base.html" %}

{% block head-title %}{{algorithm.algorithm_name}}{% endblock %}

{% block title %}{{algorithm.algorithm_name}}{% endblock %}

{% block content %}
<div style="float: right;">
	<a href="/static/{{algorithm.instance_id}}/{{algorithm.data_source_name}}"
		class="uk-button uk-button-success" target="_blank">数据文件</a>
	<a href="/show_source_code?instance_id={{algorithm.instance_id}}"
		class="uk-button uk-button-primary" target="_blank">源代码</a>
</div>
<h2>数据源</h2>
<table class="uk-table uk-table-striped">
	<caption>记录数:{{algorithm.data_source_size}}</caption>
	<thead>
		<tr>
			<th>序号</th> 
			{% for column in algorithm.data_source.columns %}
			<th>{{ column }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in algorithm.data_source.head.values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>
<hr />

<h2>模型</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>项目</th>
			<th>内容</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>输入字段</td>
			<td>{{ algorithm.input_field_names|join:"|" }}</td>
		</tr>
		<tr>
			<td>输出字段</td>
			<td>{{ algorithm.output_field_name }}</td>
		</tr>
		
		{% ifequal algorithm.algorithm_name "多项式回归" %}
		<tr>
			<td>阶数</td>
			<td>{{ algorithm.degree }}</td>
		</tr>
		{% endifequal %}
		
		
		<tr>
			<td>训练样本数</td>
			<td>{{ algorithm.train_inputs|length }}</td>
		</tr>
		<tr>
			<td>测试样本数</td>
			<td>{{ algorithm.test_inputs|length }}</td>
		</tr>
		<tr>
			<td>模型评分(训练)</td>
			<td>{{ algorithm.train_score | floatformat:2 }}</td>
		</tr>
		<tr>
			<td>模型评分(测试)</td>
			<td>{{ algorithm.test_score | floatformat:2 }}</td>
		</tr>
		{% ifequal algorithm.input_field_names|length 1 %}
		<tr>
			<td>拟合图</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/chart.png" title="点击查看大图" target="_blank">
					<img src="/static/{{algorithm.instance_id}}/chart/chart.png" width="300px"/>
				</a>
			</td>
		</tr>
		{% endifequal %}
	</tbody>
</table>
<hr />

<h2>预测</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>序号</th>
			{% for name in predict_column_names %}
			<th>{{ name }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in predict_values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>

{% endblock %}